﻿<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>模拟数字钟</title>

    <script src="/static/v0/js/jquery.min.js"></script>

    <style>
        @import url("https://fonts.googleapis.com/css?family=BenchNine:300,400");

        *, *:after, *:before {
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
        }

        html {
            background: #222;
            overflow: hidden;
            font-family: 'BenchNine', sans-serif;
        }

        .clock-container {
            position: fixed;
            left: 50%;
            top: 50%;
            -webkit-transform: translate(-50%, -50%);
            transform: translate(-50%, -50%);
            width: 480px;
            height: 480px;
            border-radius: 50%;
            overflow: hidden;
            background: #111;
            -webkit-box-shadow: 0 0 25px 3px #000, 0 0 10px rgba(0, 0, 0, 0.8) inset;
            box-shadow: 0 0 25px 3px #000, 0 0 10px rgba(0, 0, 0, 0.8) inset;
        }

        .clock-container .spear {
            position: absolute;
            width: 220px;
            height: 1px;
            background: red;
            left: 50%;
            top: 50%;
            -webkit-transform: translateY(-50%);
            transform: translateY(-50%);
            z-index: 200;
            -webkit-box-shadow: 0 3px 3px rgba(0, 0, 0, 0.4);
            box-shadow: 0 3px 3px rgba(0, 0, 0, 0.4);
        }

        .clock-container .spear:after {
            content: '';
            position: absolute;
            border: 7px solid transparent;
            border-right-color: red;
            right: 0;
            top: -7px;
        }

        .clock-container .spear:before {
            content: '';
            position: absolute;
            border: 7px solid transparent;
            border-left-color: red;
            left: 2px;
            top: -7px;
        }

        .clock-container .clock-analog {
            width: 440px;
            height: 440px;
            border-radius: 50%;
            margin: 20px;
            background: #fff;
            z-index: 5;
            position: relative;
            -webkit-box-shadow: 0 0 25px 3px #000 inset;
            box-shadow: 0 0 25px 3px #000 inset;
        }

        .clock-container .clock-analog .second, .clock-container .clock-analog .minute, .clock-container .clock-analog .hour {
            width: 20px;
            height: 20px;
            position: absolute;
            left: 0;
            top: 0;
            right: 0;
            bottom: 0;
            margin: auto;
            z-index: 100;
            -webkit-transition: 0.2s 0.2s ease-in;
            transition: 0.2s 0.2s ease-in;
            -webkit-transform: rotate(90deg);
            transform: rotate(90deg);
        }

        .clock-container .clock-analog .second span, .clock-container .clock-analog .minute span, .clock-container .clock-analog .hour span {
            position: absolute;
            width: 20px;
            height: 20px;
            line-height: 20px;
            text-align: center;
            -webkit-transform-origin: 50%;
            transform-origin: 50%;
            z-index: 5;
        }

        .clock-container .clock-analog .second span:after, .clock-container .clock-analog .minute span:after, .clock-container .clock-analog .hour span:after {
            content: '';
            width: 4px;
            height: 1px;
            background: #000;
            position: absolute;
            left: 130%;
            top: -10%;
            opacity: 0.3;
        }

        .clock-container .clock-analog .second span:nth-child(5n + 2):after, .clock-container .clock-analog .minute span:nth-child(5n + 2):after, .clock-container .clock-analog .hour span:nth-child(5n + 2):after {
            width: 7px;
            opacity: 1;
            left: 110%;
        }

        .clock-container .clock-analog .hour {
            z-index: 150;
            font-size: 32px;
            font-weight: 400;
        }

        .clock-container .clock-analog .hour span:after {
            opacity: 1;
            width: 4px;
            height: 1px;
            color: #666;
            -webkit-transform: translate(5px, 12px);
            transform: translate(5px, 12px);
        }

        .clock-container .clock-analog .hour:after {
            content: '';
            background: #fff;
            position: absolute;
            left: 50%;
            top: 50%;
            -webkit-transform: translate(-50%, -50%);
            transform: translate(-50%, -50%);
            width: 250px;
            height: 250px;
            border-radius: 50%;
            -webkit-box-shadow: 0 0 15px 2px rgba(0, 0, 0, 0.6) inset;
            box-shadow: 0 0 15px 2px rgba(0, 0, 0, 0.6) inset;
        }

        .clock-container .clock-analog .minute {
            color: #fff;
            font-size: 16px;
        }

        .clock-container .clock-analog .minute span:after {
            background: #fff;
            -webkit-transform: translate(10px, -7px) rotate(-9deg);
            transform: translate(10px, -7px) rotate(-9deg);
        }

        .clock-container .clock-analog .minute:after {
            content: '';
            background: #333;
            position: absolute;
            left: 50%;
            top: 50%;
            -webkit-transform: translate(-50%, -50%);
            transform: translate(-50%, -50%);
            width: 350px;
            height: 350px;
            border-radius: 50%;
            -webkit-box-shadow: 0 0 25px 2px #000 inset;
            box-shadow: 0 0 25px 2px #000 inset;
        }

        .clock-container .clock-analog .second {
            font-size: 12px;
        }

        .clock-container .clock-analog .second span:after {
            -webkit-transform: translate(5px, -10px);
            transform: translate(5px, -10px);
        }

        .clock-container .clock-analog .dail {
            width: 20px;
            height: 20px;
            position: absolute;
            left: 0;
            top: 0;
            right: 0;
            bottom: 0;
            margin: auto;
            z-index: 100;
        }

        .clock-container .clock-analog .dail span {
            width: 20px;
            height: 20px;
            line-height: 20px;
            -webkit-transform-origin: 50%;
            transform-origin: 50%;
            text-indent: 1000px;
            overflow: hidden;
            position: absolute;
        }

        .clock-container .clock-analog .dail span:after {
            content: '';
            position: absolute;
            width: 4px;
            height: 4px;
            border-radius: 50%;
            background-color: #7d7e7d;
            *zoom: 1;
            filter: progid:DXImageTransform.Microsoft.gradient(gradientType=1, startColorstr='#FF7D7E7D', endColorstr='#FF0E0E0E');
            background-image: url('');
            background-size: 100%;
            background-image: -webkit-gradient(linear, left top, right top, from(#7d7e7d), to(#0e0e0e));
            background-image: linear-gradient(to right, #7d7e7d 0%, #0e0e0e 100%);
            left: 50%;
            top: 50%;
            -webkit-transform: translate(-50%, -50%);
            transform: translate(-50%, -50%);
        }

        .clock-container .clock-analog .dail span:nth-child(5n + 1):after {
            width: 8px;
        }

        .clock-container .clock-digital {
            position: absolute;
            z-index: 200;
            height: 444px;
            width: 224px;
            background: #090909;
            left: 18px;
            top: 18px;
            border-radius: 220px 0 0 220px;
            -webkit-box-shadow: 5px 0 15px #000;
            box-shadow: 5px 0 15px #000;
        }

        .clock-container .clock-digital:after {
            content: '';
            position: absolute;
            border: 15px solid #8e0a0a;
            border-right: none;
            height: 400px;
            width: 200px;
            border-radius: 220px 0 0 220px;
            left: 25px;
            top: 25px;
        }

        .clock-container .clock-digital .time {
            background: #111;
            position: absolute;
            right: 20px;
            top: 50%;
            -webkit-transform: translateY(-50%);
            transform: translateY(-50%);
            color: #fff;
            border-radius: 50px;
            font-size: 24px;
            padding: 2px 20px;
            -webkit-box-shadow: 0 0 15px #000 inset;
            box-shadow: 0 0 15px #000 inset;
        }

        .clock-container .clock-digital .day {
            background: #111;
            position: absolute;
            right: 20px;
            bottom: 100px;
            color: #fff;
            border-radius: 20px;
            -webkit-box-shadow: 0 0 15px #000 inset;
            box-shadow: 0 0 15px #000 inset;
            padding: 2px 20px;
            font-size: 16px;
        }

        .clock-container .clock-digital .date {
            background: #111;
            position: absolute;
            right: 20px;
            top: 100px;
            color: #fff;
            border-radius: 20px;
            font-size: 16px;
            -webkit-box-shadow: 0 0 10px #000 inset;
            box-shadow: 0 0 10px #000 inset;
            padding: 2px 20px;
        }
    </style>
</head>
<body>
<div class="clock-container">
    <div class="clock-digital">
        <div class="date"></div>
        <div class="time"></div>
        <div class="day"></div>
    </div>
    <div class="clock-analog">
        <div class="spear"></div>
        <div class="hour"></div>
        <div class="minute"></div>
        <div class="second"></div>
        <div class="dail"></div>
    </div>
</div>

<script>
    (function () {


        var months = ["January", "February", "March", "April", "May", "June",
                "July", "August", "September", "October", "November", "December"
            ],
            days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];

        function getTime() {

            var date = new Date(),
                second = date.getSeconds(),
                minute = date.getMinutes(),
                hour = date.getHours(),
                time = date.toLocaleString('en-US', {hour: 'numeric', minute: 'numeric', hour12: true}),
                day = date.getDay(),
                month = date.getMonth(),
                date = date.getDate() + ' . ' + months[month],

                ds = second * -6,
                dm = minute * -6,
                dh = hour * -30;

            $('.second').css('transform', 'rotate(' + ds + 'deg)');
            $('.minute').css('transform', 'rotate(' + dm + 'deg)');
            $('.hour').css('transform', 'rotate(' + dh + 'deg)');

            $('.time').text(time);
            $('.day').text(days[day]);
            $('.date').text(date)
        }

        function dailer(selector, size) {
            for (var s = 0; s < 60; s++) {
                $(selector).append('<span style="transform: rotate(' + 6 * s + 'deg) translateX(' + size + 'px)">' + s + '</span>')
            }
        }

        dailer('.second', 195);
        dailer('.minute', 145);
        dailer('.dail', 230);

        for (var s = 1; s < 13; s++) {
            $('.hour').append('<span style="transform: rotate(' + 30 * s + 'deg) translateX(100px)">' + s + '</span>')
        }


        setInterval(getTime, 1000);
        getTime();

    }());
</script>

</body>
</html>
